package com.shelpe.services.scheduler;

import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.SkipListener;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.batch.core.scope.StepScope;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.shelpe.services.scheduler.dto.SyncRecordDto;
import com.shelpe.services.scheduler.item.adgroup.AdgroupProcessor;
import com.shelpe.services.scheduler.item.adgroup.RptAdgroupProcessor;
import com.shelpe.services.scheduler.item.authorize.AuthorizeProcessor;
import com.shelpe.services.scheduler.item.campaign.CampaignProcessor;
import com.shelpe.services.scheduler.item.campaign.RptCampaignProcessor;
import com.shelpe.services.scheduler.item.category.CategoryProcessor;
import com.shelpe.services.scheduler.item.creative.CreativeProcessor;
import com.shelpe.services.scheduler.item.creative.RptCreativeProcessor;
import com.shelpe.services.scheduler.item.keyword.FilterKeywordProcessor;
import com.shelpe.services.scheduler.item.keyword.InsightKeywordProcessor;
import com.shelpe.services.scheduler.item.keyword.KeywordProcessor;
import com.shelpe.services.scheduler.item.keyword.QScoreProcessor;
import com.shelpe.services.scheduler.item.keyword.RptKeywordProcessor;
import com.shelpe.services.scheduler.item.keyword.WirelessQScoreProcessor;
import com.shelpe.services.scheduler.item.order.OrderCustomerProcessor;
import com.shelpe.services.scheduler.item.recommendword.RecommendWordProcessor;
import com.shelpe.services.scheduler.mongorepository.KeywordStrTempRepository;
import com.shelpe.services.scheduler.mongorepository.UnrecoverableErrorRepository;
import com.shelpe.services.scheduler.po.Adgroups;
import com.shelpe.services.scheduler.po.Campaigns;
import com.shelpe.services.scheduler.po.Category;
import com.shelpe.services.scheduler.po.KeywordStrTemp;
import com.shelpe.services.scheduler.po.SchedulerInstance;
import com.shelpe.services.scheduler.po.SyncLog;
import com.shelpe.services.scheduler.po.Users;
import com.shelpe.services.scheduler.repository.SchedulerInstanceRepository;
import com.shelpe.services.scheduler.repository.UsersRepository;
import com.shelpe.services.scheduler.syncclient.SyncRecordClient;
import com.shelpe.services.scheduler.util.Util;

import feign.Request.Options;


@Configuration
@EnableScheduling
@EnableBatchProcessing
public class DataSyncConfiguration {

	private static final Logger logger = LoggerFactory.getLogger(DataSyncConfiguration.class);

	@Autowired 
	@Qualifier("asyncJobLauncher")
	private JobLauncher jobLauncher;

	@Autowired 
	@Qualifier("jobLauncher")
	private JobLauncher jobLauncherSync;
 
	@Autowired 
	private JobBuilderFactory jobs;

	@Autowired
	private StepBuilderFactory steps;
 
	@Autowired
	private UsersRepository userRep;
	
	@Autowired
	private SyncRecordClient syncRecordClient;
 
	@Autowired
	private KeywordStrTempRepository keywordTempRep;

	//@Autowired
	//private KeywordMetricRepository metricRep;

	@Autowired
	private SchedulerInstanceRepository instanceRep;

	@Autowired
	private UnrecoverableErrorRepository errorRep;
	
	@Autowired
	@Qualifier("syncData")
	private Job syncData;
 
	@Autowired
	@Qualifier("syncWirelessQScoreData")
	private Job syncWirelessQScoreData;
 
	@Autowired
	@Qualifier("syncRptData")
	private Job syncRptData;

	@Autowired
	@Qualifier("syncRecommendWordData")
	private Job syncRecommendWordData;
 
	@Autowired
	@Qualifier("syncInsightKeywordDataFilter")
	private Job syncInsightKeywordDataFilter;
 
	@Autowired
	@Qualifier("syncInsightKeywordDataProcess")
	private Job syncInsightKeywordDataProcess;
 
	@Autowired
	@Qualifier("syncOrderCustomerData")	 
	private Job syncOrderCustomerData;
 
	@Value("${simbaschedule.instanceIndex}")//实例索引号
	private Long instanceIndex;
 
	@Value("${simbaschedule.type}")
	private String type;
	
	@Value("${simbaschedule.mainInnerUserId}")
	private String mainInnerUserId;
  
	@Autowired
	private JavaMailSender mailSender;
	 
	private JobParametersBuilder jobParametersBuilder = new JobParametersBuilder(); 
	 
 
	 @Scheduled(cron="0 40 23 * * ?")
	 public void schedule(){

		// if(type == null || !type.equals("schedulebasedata")){
		//	 logger.info(">>>>>>schedule type {}", type);
		//	 return;
		 //}
		 try {	
			 
			 errorRep.deleteAll();
			 syncRecordClient.deleteAllSyncRecord();//第一次同步先删除前一天的记录
			 
			 long instanceNum = 1;
			 Iterable<SchedulerInstance> iter = instanceRep.findAll();
			 
			 if(iter != null){
				 SchedulerInstance instance = iter.iterator().next();
				 instanceNum = instance.getTotalNum();
			 }
			
			 long pages = Util.processThreadNum();//多实例情况下，每个实例的pages要保持一致
			 long total = userRep.count();
			 long pageSize = Util.computePageSize(total, pages);
			 Date scheduleTime = new Date();
			 logger.info("schedule pages {}, pageSize {}, total {}, scheduleTime {}, type {}, instanceNum {}, instanceIndex {}, mainInnerUserId {}", pages, pageSize,total, scheduleTime.toString(), type, instanceNum, instanceIndex, mainInnerUserId);
			
			 for(long pageNo = 0; pageNo < pages; pageNo++){
				 
				 JobParameters jobParams = jobParametersBuilder.addDate("scheduleTime", scheduleTime)
							.addLong("pageNo", pageNo)
							.addLong("pageSize", pageSize)
							.addLong("subIndex", instanceIndex)
							.addLong("subPages", instanceNum)
							.addLong("userId", null)
							.addString("mainInnerUserId", mainInnerUserId)
							.toJobParameters();
				
				 jobLauncher.run(syncData, jobParams);	
			 }
			 	 
		 } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException		
				 | JobParametersInvalidException e) {
		
			 // TODO Auto-generated catch block	
			 e.printStackTrace();		
		 }
	 }
	 
	 @Scheduled(cron="0 3 1 * * ?")
	 public void scheduleWirelessQScore(){

		// if(type == null || !type.equals("scheduleinsightdata")){
		//	 logger.info(">>>>>>schedule type {}", type);
		//	 return;
		// }
		 
		 try {	
			 long instanceNum = 1;
			 Iterable<SchedulerInstance> iter = instanceRep.findAll();
			 
			 if(iter != null){
				 SchedulerInstance instance = iter.iterator().next();
				 instanceNum = instance.getTotalNum();
			 }
			
			 long pages = Util.processThreadNum();
			 pages = 2;
			 long total = userRep.count();
			 long pageSize = Util.computePageSize(total, pages);
			 Date scheduleTime = new Date();
			 logger.info("scheduleWirelessQScore pages {}, pageSize {}, total {}, scheduleTime {}, type {}, instanceNum {}, instanceIndex {}, mainInnerUserId {}", pages, pageSize,total, scheduleTime.toString(), type, instanceNum, instanceIndex, mainInnerUserId);
			
			 for(long pageNo = 0; pageNo < pages; pageNo++){
				 
				 JobParameters jobParams = jobParametersBuilder.addDate("scheduleTime", scheduleTime)
							.addLong("pageNo", pageNo)
							.addLong("pageSize", pageSize)
							.addLong("subIndex", instanceIndex)
							.addLong("subPages", instanceNum)
							.addLong("userId", null)
							.addString("mainInnerUserId", mainInnerUserId)
							.toJobParameters();
				
				 jobLauncher.run(syncWirelessQScoreData, jobParams);	
			 }
			 	 
		 } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException		
				 | JobParametersInvalidException e) {
		
			 // TODO Auto-generated catch block	
			 e.printStackTrace();		
		 }
	 }
	 
	 @Scheduled(cron="0 1 7 * * ?")
	 public void scheduleRpt(){
		 	 
		// if(type == null || !type.equals("schedulebasedata")){
		//	 logger.info(">>>>>>scheduleRpt type {}", type);
		//	 return;
		 //}	 
		 try {		
			 syncRecordClient.deleteAllSyncRecord();//第一次同步先删除前一天的记录
			 
			 long instanceNum = 1;
			 Iterable<SchedulerInstance> iter = instanceRep.findAll();
			 
			 if(iter != null){
				 SchedulerInstance instance = iter.iterator().next();
				 instanceNum = instance.getTotalNum();	 
			 }
			 
			 long pages = Util.processThreadNum();
			 long total = userRep.count();
			 long pageSize = Util.computePageSize(total, pages);
			 Date scheduleTime = new Date();
			 logger.info("scheduleRpt pages {}, pageSize {}, total {}, scheduleTime {}, type {}, instanceNum {}, instanceIndex {}, mainInnerUserId {}", pages, pageSize,total, scheduleTime.toString(), type, instanceNum, instanceIndex, mainInnerUserId);


			 for(long pageNo = 0; pageNo < pages; pageNo++){
				 
				 JobParameters jobParams = jobParametersBuilder.addDate("scheduleTime", scheduleTime)
							.addLong("pageNo", pageNo)
							.addLong("pageSize", pageSize)
							.addLong("subIndex", instanceIndex)
							.addLong("subPages", instanceNum)
							.addLong("userId", null)
							.addString("mainInnerUserId", mainInnerUserId)
							.toJobParameters();
				
				 jobLauncher.run(syncRptData, jobParams);	
			 }
			 	 
		 } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException		
				 | JobParametersInvalidException e) {
		
			 // TODO Auto-generated catch block	
			 e.printStackTrace();		
		 }
	 }
	 
	 
	 @Scheduled(cron="0 1 9 * * ?")
	 public void scheduleRptAgain(){
		 
		// if(type == null || !type.equals("schedulebasedata")){
		//	 logger.info(">>>>>>scheduleRpt type {}", type);
		//	 return;
		 //}
		 try{
			 SyncRecordDto dto = syncRecordClient.needSyncAgain();
			 if(!dto.isNeedSyncAgain()){
				 logger.info(">>>rpt has been sync, do nothing");
				 return;
			 }
			 
			 SimpleMailMessage message = new SimpleMailMessage();
	         
			 message.setFrom("15868865221@163.com");      
			 message.setTo("wuya@shelpe.com");   
			 message.setSubject("[simba]trigger double rpt sync");	      
			 message.setText("Warning: Today, first rpt sync maybe failed, I have to sync again!");    
			 mailSender.send(message);
			 
		 }catch(Exception e){
			 logger.info("error {}", e);
		 }
		 
		 try {		
			 
			 long instanceNum = 1;
			 Iterable<SchedulerInstance> iter = instanceRep.findAll();
			 
			 if(iter != null){
				 SchedulerInstance instance = iter.iterator().next();
				 instanceNum = instance.getTotalNum();	 
			 }
			 
			 long pages = Util.processThreadNum();
			 long total = userRep.count();
			 long pageSize = Util.computePageSize(total, pages);
			 Date scheduleTime = new Date();
			 logger.info("scheduleRptAgain pages {}, pageSize {}, total {}, scheduleTime {}, type {}, instanceNum {}, instanceIndex {}, mainInnerUserId {}", pages, pageSize,total, scheduleTime.toString(), type, instanceNum, instanceIndex, mainInnerUserId);


			 for(long pageNo = 0; pageNo < pages; pageNo++){
				 
				 JobParameters jobParams = jobParametersBuilder.addDate("scheduleTime", scheduleTime)
							.addLong("pageNo", pageNo)
							.addLong("pageSize", pageSize)
							.addLong("subIndex", instanceIndex)
							.addLong("subPages", instanceNum)
							.addLong("userId", null)
							.addString("mainInnerUserId", mainInnerUserId)
							.toJobParameters();
				
				 jobLauncher.run(syncRptData, jobParams);	
			 }
			 	 
		 } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException		
				 | JobParametersInvalidException e) {
		
			 // TODO Auto-generated catch block	
			 e.printStackTrace();		
		 }
	 }
	 
	 
	 @Scheduled(cron="0 3 12 * * ?")
	 public void scheduleInsightKeywordData(){	
			 
		// if(type == null || !type.equals("scheduleinsightdata")){
		//	 logger.info(">>>>>>scheduleInsightKeywordData type {}", type);
		//	 return;
		// }
		 
		 try {	
			 
			 long pages = 1;  //一个线程处理即可
			 long total = userRep.count();
			 
			 long pageSize = Util.computePageSize(total, pages);
			 Date scheduleTime = new Date();
			 logger.info("syncInsightKeywordDataFilter pages {}, pageSize {}, total {}, scheduleTime {}, type {}, instanceIndex {}, mainInnerUserId {}", pages, pageSize,total, scheduleTime.toString(), type, instanceIndex, mainInnerUserId);
			 logger.info("keywordTemp >>>>>>>>>>>>>>> num {}", keywordTempRep.count()); 
			 keywordTempRep.deleteAll();
			 
			// Map<String, String> dateMap = Util.getTaskRange();
			 
			// Date endDateFormat = new Date();
		  //  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			//try {
			//	endDateFormat = sdf.parse(dateMap.get("endDate"));
			//} catch (ParseException e) {
			//	// TODO Auto-generated catch block
			//	e.printStackTrace();
			//}
			
			//metricRep.deleteByScopeEndTime(endDateFormat);

			JobParameters jobParams = jobParametersBuilder.addDate("scheduleTime", scheduleTime)
							.addLong("pageNo", 0L)
							.addLong("pageSize", pageSize)
							.addLong("subIndex", 0L)
							.addLong("subPages", 1L)
							.addLong("userId", null)
							.addString("mainInnerUserId", mainInnerUserId)
							.toJobParameters();
				
			jobLauncherSync.run(syncInsightKeywordDataFilter, jobParams);	
			
			pages = Util.processThreadNum();
			total = keywordTempRep.count();
			pageSize = Util.computePageSize(total, pages);
			scheduleTime = new Date();
			
			logger.info("scheduleInsightKeywordDataProcess pages {}, pageSize {}, total {}, scheduleTime {}, type {}, instanceIndex {}, mainInnerUserId {}", pages, pageSize,total, scheduleTime.toString(), type, instanceIndex, mainInnerUserId);	
 
			for(long pageNo = 0; pageNo < pages; pageNo++){
				 
				 JobParameters jobParams1 = jobParametersBuilder.addDate("scheduleTime", scheduleTime)
							.addLong("pageNo", pageNo)
							.addLong("pageSize", pageSize)
							.addLong("subIndex", 0L)
							.addLong("subPages", 1L)
							.addLong("userId", null)
							.addString("mainInnerUserId", mainInnerUserId)
							.toJobParameters();
				
				 jobLauncher.run(syncInsightKeywordDataProcess, jobParams1);	
			 }
			
		 } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException		
				 | JobParametersInvalidException e) {
		
			 // TODO Auto-generated catch block	
			 e.printStackTrace();		
		 }
	 }
	 
	 @Scheduled(cron="0 10 1 * * ?")
	 public void scheduleRecommendWordData(){
		 
		// if(type == null || !type.equals("scheduleinsightdata")){
		//	 logger.info(">>>>>>scheduleOtherData type {}", type);
		//	 return;
		 //}
		 
		 try {	
			 
			 long pages = Util.processThreadNum();
			 pages = 1;
			 long total = userRep.count();
			 long pageSize = Util.computePageSize(total, pages);
			 Date scheduleTime = new Date();
			 logger.info("scheduleRecommendWordData pages {}, pageSize {}, total {}, scheduleTime {}, type {}, instanceIndex {}, mainInnerUserId {}", pages, pageSize,total, scheduleTime.toString(), type, instanceIndex, mainInnerUserId);
						
			 for(long pageNo = 0; pageNo < pages; pageNo++){
				 
				 JobParameters jobParams = jobParametersBuilder.addDate("scheduleTime", scheduleTime)
							.addLong("pageNo", pageNo)
							.addLong("pageSize", pageSize)
							.addLong("subIndex", 0L)
							.addLong("subPages", 1L)
							.addLong("userId", null)
							.addString("mainInnerUserId", mainInnerUserId)
							.toJobParameters();
				
				 jobLauncher.run(syncRecommendWordData, jobParams);	
			 }
			 	 
		 } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException		
				 | JobParametersInvalidException e) {
		
			 // TODO Auto-generated catch block	
			 e.printStackTrace();		
		 }
	 }
	 
	 
	 //@Scheduled(cron="0 55 14 * * ?")
	 public void scheduleOrderCustomerData(){
		 
		// if(type == null || !type.equals("scheduleinsightdata")){
		//	 logger.info(">>>>>>scheduleOtherData type {}", type);
		//	 return;
		 //}
		 
		 try {	
			 
			 long pages = Util.processThreadNum();
			 pages = 1;
			 long total = userRep.count();
			 long pageSize = Util.computePageSize(total, pages);
			 Date scheduleTime = new Date();
			 logger.info("scheduleOrderCustomerData pages {}, pageSize {}, total {}, scheduleTime {}, type {}, instanceIndex {}, mainInnerUserId {}", pages, pageSize,total, scheduleTime.toString(), type, instanceIndex, mainInnerUserId);
						
			 for(long pageNo = 0; pageNo < pages; pageNo++){
				 
				 JobParameters jobParams = jobParametersBuilder.addDate("scheduleTime", scheduleTime)
							.addLong("pageNo", pageNo)
							.addLong("pageSize", pageSize)
							.addLong("subIndex", 0L)
							.addLong("subPages", 1L)
							.addLong("userId", null)
							.addString("mainInnerUserId", mainInnerUserId)
							.toJobParameters();
				
				 jobLauncher.run(syncOrderCustomerData, jobParams);	
			 }
			 	 
		 } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException		
				 | JobParametersInvalidException e) {
		
			 // TODO Auto-generated catch block	
			 e.printStackTrace();		
		 }
	 } 
	 
	 
	 @Bean
	 public Job syncData(@Qualifier("userStepTest") Step step1, 
			 @Qualifier("subWayTokenStepTest") Step step2, @Qualifier("productStepTest") Step step3, 
			 @Qualifier("campaignStepTest") Step step4, @Qualifier("adgroupStepTest") Step step5, 
			 @Qualifier("creativeStepTest") Step step6, @Qualifier("keywordStepTest") Step step7,
			 @Qualifier("keywordScoreStepTest") Step step8) {
	    
		 return jobs.get("syncDataScheduler")
						.start(step1)
						.next(step2)
						.next(step3)
						.next(step4)
						.next(step5)
						.next(step6)
						.next(step7) 
						.next(step8)
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncWirelessQScoreData(@Qualifier("keywordScoreWirelessStepTest") Step step1) {
	    
		 return jobs.get("syncWirelessQScoreDataScheduler")
						.start(step1)
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncRptData(@Qualifier("customerStepTest") Step step1, @Qualifier("rptCampaignStepTest") Step step2,  
			 @Qualifier("rptAdgroupStepTest") Step step3, @Qualifier("rptCreativeStepTest") Step step4,
			 @Qualifier("rptKeywordStepTest") Step step5, @Qualifier("orderCustomerStepTest") Step step6) {
	    
		 return jobs.get("syncRptDataScheduler")
						.start(step1)
						.next(step2)
						.next(step3)
						.next(step4)
						.next(step5)
						.next(step6)
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncRecommendWordData(@Qualifier("recommendWordStepTest") Step step1) {
	    
		 return jobs.get("syncRecommendWordDataScheduler")
						.start(step1)
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncInsightKeywordDataFilter(@Qualifier("filterKeywordDataTest") Step step1) {
	    
		 return jobs.get("syncInsightKeywordDataScheduler")
						.start(step1)
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncInsightKeywordDataProcess(@Qualifier("insightKeywordDataTest") Step step1, @Qualifier("insightCategoryStepTest") Step step2) {
	    
		 return jobs.get("syncInsightKeywordDataScheduler")
						.start(step1)
						.next(step2)
						.build();	 
	 }
	 
	 
	 @Bean  
	 public Job syncSingleUserData(@Qualifier("userStepTest") Step step1, @Qualifier("subWayTokenStepTest") Step step2, 
			 @Qualifier("productStepTest") Step step3, @Qualifier("campaignStepTest") Step step4,
			 @Qualifier("customerStepTest") Step step5, @Qualifier("adgroupStepTest") Step step6, 
			 @Qualifier("keywordStepTest") Step step7, @Qualifier("creativeStepTest") Step step8,
			 @Qualifier("rptCampaignStepTest") Step step9, @Qualifier("rptAdgroupStepTest") Step step10, 
			 @Qualifier("rptCreativeStepTest") Step step11, @Qualifier("rptKeywordStepTest") Step step12) {
	    
		 return jobs.get("syncSingleUserDataScheduler")
						.start(step1)
						.next(step2)
						.next(step3)
						.next(step4)
						.next(step5)
						.next(step6)
						.next(step7)
						.next(step8)
						.next(step9)
						.next(step10)
						.next(step11)
						.next(step12)
						.build();	 
	 }
	 
	 
	 @Bean  
	 public Job syncSingleUserBaseData(@Qualifier("userStepTest") Step step1, @Qualifier("subWayTokenStepTest") Step step2, 
			 @Qualifier("productStepTest") Step step3, @Qualifier("campaignStepTest") Step step4,
			 @Qualifier("customerStepTest") Step step5, @Qualifier("adgroupStepTest") Step step6,
			 @Qualifier("rptCampaignStepTest") Step step7, @Qualifier("userStepTest") Step step8) {
	    
		 return jobs.get("syncSingleUserBaseDataScheduler")
						.start(step1)
						.next(step2)
						.next(step3)
						.next(step4)
						.next(step5)
						.next(step6)
						.next(step7)
						.next(step8)
						.build();	 
	 }

	 @Bean  
	 public Job syncSingleUserRptCustomerData(@Qualifier("customerStepTest") Step step1) {
	    
		 return jobs.get("syncSingleUserRptCustomerDataScheduler")
						.start(step1)	
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncSingleUserRptCampaignData(@Qualifier("rptCampaignStepTest") Step step1) {
	    
		 return jobs.get("syncSingleUserRptCampaignDataScheduler")
						.start(step1)	
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncSingleUserRptAdgroupData(@Qualifier("singleUserRptAdgroupStepTest") Step step1) {
	    
		 return jobs.get("syncSingleUserRptAdgroupDataScheduler")
						.start(step1)	
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncSingleUserCreativeData(@Qualifier("singleUserCreativeStepTest") Step step1) {
	    
		 return jobs.get("syncSingleUserCreativeDataScheduler")
						.start(step1)
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncSingleUserRptCreativeData(@Qualifier("singleUserRptCreativeStepTest") Step step1) {
	    
		 return jobs.get("syncSingleUserRptCreativeDataScheduler")
						.start(step1)
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncSingleUserKeywordData(@Qualifier("singleUserKeywordStepTest") Step step1,
			 		@Qualifier("singleUserKeywordScoreStepTest") Step step2) {
	    
		 return jobs.get("syncSingleUserKeywordDataScheduler")
						.start(step1)
						.next(step2)
						.build();	 
	 }
	 
	 @Bean  
	 public Job syncSingleUserRptKeywordData(@Qualifier("singleUserRptKeywordStepTest") Step step1,
			 		@Qualifier("singleUserRecommendWordStepTest") Step step2) {
	    
		 return jobs.get("syncSingleUserRptKeywordDataScheduler")
						.start(step1)
						.next(step2)
						.build();	 
	 }
	 
	 
	 @Bean 
	 public Job syncOrderCustomerData(@Qualifier("orderCustomerStepTest") Step step1) {
	    
		 return jobs.get("syncOrderCustomerDataScheduler")
						.start(step1)
						.build();	  
	 }
	 
	
	 @Bean 
	 protected Step userStepTest(@Qualifier("userReader") ItemReader<Users> reader,
			 @Qualifier("userProcessor") ItemProcessor<Users, SyncLog> processor,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("userSkipListener") SkipListener<Users, SyncLog> skipListener){
 
		 return steps.get("userStep")
						.<Users, SyncLog> chunk(20)
						.reader(reader)
						.processor(processor)
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(100)
						.build();
	 }
	 
	 @Bean 
	 protected Step subWayTokenStepTest(@Qualifier("userReader") ItemReader<Users> reader,
			 @Qualifier("subWayTokenProcessor") ItemProcessor<Users, SyncLog> processor,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("userSkipListener") SkipListener<Users, SyncLog> skipListener){
 
		 return steps.get("subWayTokenStep")
						.<Users, SyncLog> chunk(20)
						.reader(reader)
						.processor(processor)
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(100)
						.build();
	 }
	 
	 @Bean 
	 protected Step productStepTest(@Qualifier("userReader") ItemReader<Users> reader,
			 @Qualifier("productProcessor") ItemProcessor<Users, SyncLog> processor,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("productSkipListener") SkipListener<Users, SyncLog> skipListener){
 
		 return steps.get("productStep")
						.<Users, SyncLog> chunk(1)
						.reader(reader)
						.processor(processor)
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(100)
						.build();
	 }
	 
	 
	 @Bean 
	 protected Step campaignStepTest(@Qualifier("userReader")ItemReader<Users> userReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("campaignSkipListener") SkipListener<Users, SyncLog> skipListener){
	
		 return steps.get("campaignStep")
						.<Users, SyncLog> chunk(1)
						.reader(userReader)
						.processor(campaignProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
						.skipLimit(100)
						.build();
	 }
	 
	 @Bean 
	 protected Step rptCampaignStepTest(@Qualifier("userReader")ItemReader<Users> userReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("rptCampaignSkipListener") SkipListener<Users, SyncLog> skipListener){
	
		 return steps.get("rptCampaignStep")
						.<Users, SyncLog> chunk(1)
						.reader(userReader)
						.processor(rptCampaignProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
						.skipLimit(100)
						.build();
	 }
	 
	 
	 @Bean 
	 protected Step adgroupStepTest(@Qualifier("campaignReaderTest")ItemReader<Campaigns> campaignReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("adgroupSkipListener") SkipListener<Campaigns, SyncLog> skipListener){
 
		 return steps.get("adgroupStep")			 
						.<Campaigns, SyncLog> chunk(8)
						.reader(campaignReader)
						.processor(adgroupProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(200)
						.build();
	 }
	 
	 @Bean 
	 protected Step singleUserAdgroupStepTest(@Qualifier("singleUserCampaignReader")ItemReader<Campaigns> campaignReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("adgroupSkipListener") SkipListener<Campaigns, SyncLog> skipListener){
 
		 return steps.get("singleUserAdgroupStep")			 
						.<Campaigns, SyncLog> chunk(8)
						.reader(campaignReader)
						.processor(adgroupProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(200)
						.build();
	 }
	 
	 @Bean 
	 protected Step rptAdgroupStepTest(@Qualifier("campaignReaderTest")ItemReader<Campaigns> campaignReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("rptAdgroupSkipListener") SkipListener<Campaigns, SyncLog> skipListener){
 
		 return steps.get("rptAdgroupStep")			 
						.<Campaigns, SyncLog> chunk(8)
						.reader(campaignReader)
						.processor(rptAdgroupProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(200)
						.build();
	 }
	 
	 @Bean 
	 protected Step singleUserRptAdgroupStepTest(@Qualifier("singleUserCampaignReader")ItemReader<Campaigns> campaignReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("rptAdgroupSkipListener") SkipListener<Campaigns, SyncLog> skipListener){
 
		 return steps.get("singleUserRptAdgroupStep")			 
						.<Campaigns, SyncLog> chunk(8)
						.reader(campaignReader)
						.processor(rptAdgroupProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(200)
						.build();
	 }
	 
	 @Bean 
	 protected Step creativeStepTest(@Qualifier("adgroupReaderTest")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("creativeSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
		 
		 return steps.get("creativeStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(creativeProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step singleUserCreativeStepTest(@Qualifier("singleUserAdgroupReader")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("creativeSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
		 
		 return steps.get("singleUserCreativeStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(creativeProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step rptCreativeStepTest(@Qualifier("adgroupReaderTest")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("rptCreativeSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
		 
		 return steps.get("rptCreativeStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(rptCreativeProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step singleUserRptCreativeStepTest(@Qualifier("singleUserAdgroupReader")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("rptCreativeSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
		 
		 return steps.get("singleUserRptCreativeStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(rptCreativeProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step keywordStepTest(@Qualifier("adgroupReaderTest")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("keywordSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("keywordStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(keywordProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step singleUserKeywordStepTest(@Qualifier("singleUserAdgroupReader")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("keywordSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("singleUserKeywordStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(keywordProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step keywordScoreStepTest(@Qualifier("adgroupReaderTest")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("qScoreSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("keywordScoreStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(keywordScoreProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step keywordScoreWirelessStepTest(@Qualifier("adgroupReaderTest")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("wirelessQScoreSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("keywordScoreWirelessStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(keywordScoreWirelessProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 
	 @Bean 
	 protected Step singleUserKeywordScoreStepTest(@Qualifier("singleUserAdgroupReader")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("qScoreSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("singleUserKeywordScoreStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(keywordScoreProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step filterKeywordDataTest(@Qualifier("adgroupReaderTest")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("filterKeywordSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("filterKeywordDataStep")
						.<Adgroups, SyncLog> chunk(200)
						.reader(adgroupReader)
						.processor(filterKeywordProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step insightKeywordDataTest(@Qualifier("insightKeywordReaderTest")ItemReader<List<KeywordStrTemp> > insightKeywordReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("insightKeywordSkipListener") SkipListener<List<KeywordStrTemp>, SyncLog> skipListener){
 
		 return steps.get("insightKeywordDataStep")
						.<List<KeywordStrTemp>, SyncLog> chunk(1)
						.reader(insightKeywordReader)
						.processor(insightKeywordDataProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(100)
						.build();
	 }
	 
	 
	 @Bean 
	 protected Step rptKeywordStepTest(@Qualifier("adgroupReaderTest")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("rptKeywordSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("rptKeywordStep")
						.<Adgroups, SyncLog> chunk(100)
						.reader(adgroupReader)
						.processor(rptKeywordProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(800)
						.build();
	 }
	 
	 @Bean 
	 protected Step singleUserRptKeywordStepTest(@Qualifier("singleUserAdgroupReader")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("rptKeywordSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("singleUserRptKeywordStep")
						.<Adgroups, SyncLog> chunk(20)
						.reader(adgroupReader)
						.processor(rptKeywordProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(200)
						.build();
	 }
	 
	 @Bean 
	 protected Step customerStepTest(@Qualifier("userReader")ItemReader<Users> userReader,
			 @Qualifier("customerProcessor") ItemProcessor<Users, SyncLog> processor,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("rptCustomerSkipListener") SkipListener<Users, SyncLog> skipListener){
		 
		 return steps.get("customerStep")
						.<Users, SyncLog> chunk(1)
						.reader(userReader)
						.processor(processor)
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(100)
						.build();
	 }
	 
	 @Bean 
	 protected Step customerRptRealTimeStepTest(@Qualifier("userReader")ItemReader<Users> userReader,
			 @Qualifier("rptRealTimeProcessor") ItemProcessor<Users, SyncLog> processor,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("userSkipListener") SkipListener<Users, SyncLog> skipListener){
		 
		 return steps.get("customerRptRealTimeStep")
						.<Users, SyncLog> chunk(1)
						.reader(userReader)
						.processor(processor)
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(100)
						.build();
	 }
	 
	 @Bean
	 protected Step recommendWordStepTest(@Qualifier("adgroupReaderTest")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("recommendWordSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
		 
		 return steps.get("recommendWordStep")
					.<Adgroups, SyncLog> chunk(50)
					.reader(adgroupReader)
					.processor(recommendWordProcessorTest())
					.writer(userWriter)
					.faultTolerant()
					.listener(skipListener)
					.retry(Exception.class)
					.retryLimit(2)
					.skip(Exception.class)
                    .skipLimit(500)
					.build();
	 }

	 @Bean 
	 protected Step singleUserRecommendWordStepTest(@Qualifier("singleUserAdgroupReader")ItemReader<Adgroups> adgroupReader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter, 
			 @Qualifier("recommendWordSkipListener") SkipListener<Adgroups, SyncLog> skipListener){
 
		 return steps.get("singleUserRecommendWordStep")
						.<Adgroups, SyncLog> chunk(50)
						.reader(adgroupReader)
						.processor(recommendWordProcessorTest())
						.writer(userWriter)
						.faultTolerant()
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(500)
						.build();
	 }
	 
	 @Bean 
	 protected Step orderCustomerStepTest(@Qualifier("orderCustomerReaderTest")ItemReader<Long> reader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("orderCustomerSkipListener") SkipListener<Long, SyncLog> skipListener){
 
		 return steps.get("orderCustomerStep")
						.<Long, SyncLog> chunk(1)
						.reader(reader)
						.processor(orderCustomerProcessorTest())
						.writer(userWriter)
						.faultTolerant()	
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(5)
						.build();
	 }
	 
	 @Bean 
	 protected Step insightCategoryStepTest(@Qualifier("categoryReader")ItemReader<List<Category> > reader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("categorySkipListener") SkipListener<List<Category>, SyncLog> skipListener){
 
		 return steps.get("insightCategoryStep")
						.<List<Category>, SyncLog> chunk(20)
						.reader(reader)
						.processor(categoryProcessorTest())
						.writer(userWriter)
						.faultTolerant()	
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(100)
						.build();
	 }
	 
	 @Bean 
	 protected Step authorizeStepTest(@Qualifier("authorizeReader")ItemReader<Long> reader,
			 @Qualifier("userWriter") ItemWriter<SyncLog> userWriter,
			 @Qualifier("authorizeSkipListener") SkipListener<Long, SyncLog> skipListener){
 
		 return steps.get("authorizeStep")
						.<Long, SyncLog> chunk(1)
						.reader(reader)
						.processor(authorizeProcessorTest())
						.writer(userWriter)
						.faultTolerant()	
						.listener(skipListener)
						.retry(Exception.class)
						.retryLimit(2)
						.skip(Exception.class)
                        .skipLimit(10)
						.build();
	 }
	 
	 @Bean
	 protected ItemProcessor<Users, SyncLog> campaignProcessorTest(){
		 
		 return new CampaignProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Users, SyncLog> rptCampaignProcessorTest(){
		 
		 return new RptCampaignProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Campaigns, SyncLog> adgroupProcessorTest(){
		 
		 return new AdgroupProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Campaigns, SyncLog> rptAdgroupProcessorTest(){
		 
		 return new RptAdgroupProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Adgroups, SyncLog> creativeProcessorTest(){
		 
		 return new CreativeProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Adgroups, SyncLog> rptCreativeProcessorTest(){
		 
		 return new RptCreativeProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Adgroups, SyncLog> keywordProcessorTest(){
		 
		 return new KeywordProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Adgroups, SyncLog> keywordScoreProcessorTest(){
		 
		 return new QScoreProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Adgroups, SyncLog> keywordScoreWirelessProcessorTest(){
		 
		 return new WirelessQScoreProcessor();
	 }
	
	 @Bean
	 protected ItemProcessor<Adgroups, SyncLog> filterKeywordProcessorTest(){
		 
		 return new FilterKeywordProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<List<KeywordStrTemp>, SyncLog> insightKeywordDataProcessorTest(){
		 
		 return new InsightKeywordProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Adgroups, SyncLog> rptKeywordProcessorTest(){
		 
		 return new RptKeywordProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Adgroups, SyncLog> recommendWordProcessorTest(){
		 
		 return new RecommendWordProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Long, SyncLog> orderCustomerProcessorTest(){
		 
		 return new OrderCustomerProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<List<Category>, SyncLog> categoryProcessorTest(){
		 
		 return new CategoryProcessor();
	 }
	 
	 @Bean
	 protected ItemProcessor<Long, SyncLog> authorizeProcessorTest(){
		 
		 return new AuthorizeProcessor();
	 }
     
     @Bean
     public static StepScope scope(){
         
         return new StepScope();
     }
     
     @Bean
     public TaskExecutor syncTaskExecutor(){
    	 
    	 return new SimpleAsyncTaskExecutor();
     }
     
     @Bean
     @Autowired
     public JobLauncher asyncJobLauncher(@Qualifier("syncTaskExecutor")TaskExecutor taskExecutor, JobRepository jobRepository){
    	 
    	 SimpleJobLauncher jobLan = new SimpleJobLauncher();  
    	 jobLan.setJobRepository(jobRepository);    	
    	 jobLan.setTaskExecutor(taskExecutor);
    	 
    	 return jobLan;
     }
     
	
     @Bean
     public Options feignRequestOptions(){
    	 return new Options(10 * 1000, 3 * 60 * 1000);
     }

     
}